/***     
 * 查找同花色的牌
 */

var _ = require('../Underscore');
var CardTool = require('./../CardTool');
var FindCardTool = module.exports = {};

/***
 * 获得相同牌数量
 * _cardInfoList:[{"cardId":64,"type":2,"value":12},{"cardId":22,"type":2,"value":9}]//牌信息
 * findCb:找到的条件
 * noFindCb：找不到的条件
 */
FindCardTool.getResult = function(_cardInfoList, findCb, noFindCb) {
    var findGroup = _.filter(_cardInfoList, findCb);
    if (0 == _.size(findGroup)) {
        // console.error("未找到%d花色", cardType);
        return {
            isFind: false,
            findGroup: [],
            otherGroup: _cardInfoList
        };
    }
    var otherGroup = _.filter(_cardInfoList, noFindCb);
    //还原为一级数组
    otherGroup = _.flatten(otherGroup);
    var result = {
        isFind: true,
        findGroup: findGroup,
        otherGroup: otherGroup
    };
    // console.error("查找%d同结果:%s", sameNumber, JSON.stringify(result));  
    return result;
};